<?= isset($header) ? $header : '' ?>
<script src="/js/demand_pair.js"></script>
<script type="text/Javascript" src="/js/map.js"></script>

<script type="text/javascript">
	function demand_pair() {
		var demand_id = $("#demand_id").val();
		var url = '/pair/demand?id=' + demand_id;
		document.location.href = url;
	}
</script>


<div id="content">
    <form method="post" action="<?= site_url('/demand/data_edit_submit') ?>">
        <div style="overflow:visible;" class="form_style">
            <div class="title">
                <h5>需求資料
                    <?php if (empty($display)) { ?>
                        修改
                        &nbsp;

                        <input 	type="button"
                                onclick="demand_pair()"
                                value="單筆配對"
                                class="input_background"
                                name="pair_submit"
                                id="pair_submit">
                            <?php } ?>
                </h5>
            </div>


            <div id="userinfo">
                <!-- start -->
                <table>
                    <tbody>
                        <tr>
                            <th class="must_write">需求類型</th>
                            <td>

                                <input type="hidden" name="demand_id" id="demand_id" value="<?= $demand -> demand_id; ?>"  >

                                <input type="hidden" name="type_rent" value="<?= $demand -> type_rent; ?>"  >
                                <input type="hidden" name="type_sell" value="<?= $demand -> type_sell; ?>"  >
                                <input type="hidden" name="type_consignment" value="<?= $demand -> type_consignment ?>"  >




                                
								買賣
                                <input type="checkbox" name="type_sell" value="<?= $demand -> type_sell ?>"
                                       disabled="disabled"
                                       <?php
									if ($demand -> type_sell == "1") {
										echo "checked='true'";
									}
                                       ?> >

                                租賃
                                <input type="checkbox" name="type_rent" value="<?= $demand -> type_rent ?>"
                                       disabled="disabled"
                                       <?php
									if ($demand -> type_rent == "1") {
										echo "checked='true'";
									}
                                       ?> >

                                <!--
                                        代銷
                                        <input type="checkbox" name="type_consignment" value="<?= $demand->type_consignment ?>"
                                        disabled="disabled"
                                <?php
                                //if($demand->type_consignment=="1"){
                                //	echo "checked='true'";
                                //}
                                ?>
                                        >
                                -->


                            </td>
                            <th>物件用途</th>
                            <td >
                            		<input  type="type" id="object_usage" name="object_usage" class="full_select" value="<?=$demand->object_usage?>">
                            	
                                
                            </td>



                            
                            </tr>

                            <tr>
                                <th class="color1">建物面積</th>
                                <td>
                                    <input type="text" style="width:50px;height:20px;" id="building_area1" name="building_area1" value="<?= intval($demand -> building_area1) ?>">
                                    ~ <input type="text" style="width:50px;height:20px;" id="building_area2" name="building_area2" value="<?= intval($demand -> building_area2) ?>">
                                    坪
                                </td>
                                <th class="color1">車位數</th>
                                <td>
                                    <input type="text" id="parking_number" style="width:24px;height:20px;" name="parking_number" value="<?= $demand -> parking_number ?>">&nbsp;個
                                    <input type="checkbox" value="1" <?
									if ($demand -> acceptable_mechanical == 1)
										echo "checked";
                                           ?> id="acceptable_mechanical" name="acceptable_mechanical">可接受機械
                                </td>

                                <th class="color1">土地面積</th>
                                <td>
                                    <input type="text" style="width:50px;height:20px;" id="land_area1" name="land_area1" value="<?= intval($demand -> land_area1) ?>">
                                    ~ <input type="text" style="width:50px;height:20px;" id="land_area2" name="land_area2" value="<?= intval($demand -> land_area2) ?>">
                                    坪
                                </td>

                                <th>分區使用</th>
                                <td>
                                	<input type="text" id="partition_the" name="partition_the" value="<?=$demand -> partition_the?>">
                                    
                                        <?
                                     //   foreach($land_use_zoning as $key=>$val){
                                        ?>
                                       
                                </td>
                            </tr>

                            <tr>
                                <th title="不含陽台.不含附屬" class="color1">室內面積</th>
                                <td>
                                    <input type="text" style="width:50px;height:20px;" name="indoor_area1" id="indoor_area1" value="<?= intval($demand -> indoor_area1) ?>">
                                    ~ <input type="text" style="width:50px;height:20px;" name="indoor_area2" id="indoor_area2" value="<?= intval($demand -> indoor_area2) ?>">
                                    坪
                                </td>

                                <th style="width:75px;">樓地板高度</th>
                                <td>
                                    <input type="text" style="width:104px;" id="floor_height" name="floor_height" value="<?= intval($demand -> floor_height) ?>">M
                                </td>
                                
                                <th style="width:75px;">需求編號</th>
                                <td>
                                    <input type="text" style="width:204px;" id="demand_serial" name="demand_serial" value="<?= $demand -> demand_serial ?>">
                                </td>

                            </tr>

                            <tr>
                                <th class="color2">重點區域</th>
                                <td colspan="3">
                                    <input type="text"  id="key_areas1" name="key_areas1" value="<?= $demand -> key_areas1 ?>" onclick="show_emphasis_area('key_areas1')">
                                    <input type="text"  id="key_areas2" name="key_areas2" value="<?= $demand -> key_areas2 ?>" onclick="show_emphasis_area('key_areas2')">
                                </td>
                                <th class="color2">指定大樓</th>
                                <td colspan="3">
                                    <input type="text" id="specify_building1" name="specify_building1" value="<?= $demand -> specify_building1 ?>" onclick="show_building_name('specify_building1')">
                                    <input type="text" id="specify_building2" name="specify_building2" value="<?= $demand -> specify_building2 ?>" onclick="show_building_name('specify_building2')">
                                </td>
                            </tr>
                    </table>



                        <table>
                            <tr>
                                <th class="color2"  style="background-color: honeydew;color: black;" >
                            <div >
                                <a onclick="show_surroundings();" class="additem">
                                    <i id="surroundings_icon" class="icon-plus">
                                        &nbsp;&nbsp;
                                    </i>
                                </a>
                                &nbsp;路段
                            </div>
                            </th>
                            <td colspan="3">
                                <input type="text"  id="sections1" name="sections1" value="<?= $demand -> sections1 ?>" onclick="show_address('sections1');">
                                <input type="text"  id="sections2" name="sections2" value="<?= $demand -> sections2 ?>" onclick="show_address('sections2');">
                            </td>
                            <th class="color2"  style="background-color: honeydew;color: black;">物件案名
                            </th>
                            <td colspan="3">
                                <input type="text" id="object_name1" name="object_name1" value="<?= $demand -> object_name1 ?>" onclick="show_object_case_name('object_name1');">
                                <input type="text" id="object_name2" name="object_name2" value="<?= $demand -> object_name2 ?>" onclick="show_object_case_name('object_name2');">
                            </td>
                            </tr>
                            </tbody>

                                <tbody  id="surroundings" style="display: none;">
                                    <tr>
                                        <th class="color2"  style="background-color: honeydew;color: black;">捷運</th>
                                        <td colspan="3" >
                                            <select onchange="get_line(1);" class="full_select" style="width:100px;" name="mrt_line1" id="mrt_line1">
                                                <option value="">&nbsp;&nbsp;</option>
                                                <?
                                                foreach($mrt_line as $key=>$val){
                                                ?>
                                                <option value="<?= $val -> mrt_line_id ?>" <?
												if ($demand -> mrt_line1 == $val -> mrt_line_id)
													echo "selected";
                                                        ?>><?= $val -> value ?></option>
                                                <?
												}
                                                ?>
                                            </select>
                                            起：
                                            <select id="mrt_start1" class="full_select" style="width:100px;" name="mrt_start1">
                                                <option value="">&nbsp;&nbsp;&nbsp;&nbsp;</option>
                                                <?
                                                if($demand->mrt_line1>0){
                                                foreach($mrt[$demand->mrt_line1] as $key=>$val){
                                                ?>
                                                <option value="<?= $key ?>" <?
												if ($demand -> mrt_start1 == $key)
													echo "selected";
                                                        ?>><?= $val ?></option>
                                                <?
												}
												}
                                                ?>
                                            </select>
                                            迄：
                                            <select id="mrt_until1" class="full_select" style="width:100px;" name="mrt_until1">
                                                <option value="">&nbsp;&nbsp;&nbsp;&nbsp;</option>
                                                <?
                                                if($demand->mrt_line1>0){
                                                foreach($mrt[$demand->mrt_line1] as $key=>$val){
                                                ?>
                                                <option value="<?= $key ?>" <?
												if ($demand -> mrt_until1 == $key)
													echo "selected";
                                                        ?>><?= $val ?></option>
                                                <?
												}
												}
                                                ?>
                                            </select>
                                            <br>
                                            <select onchange="get_line(2);" class="full_select" style="width:100px;" name="mrt_line2" id="mrt_line2">
                                                <option value="">&nbsp;&nbsp;</option>
                                                <?
                                                foreach($mrt_line as $key=>$val){
                                                ?>
                                                <option value="<?= $val -> mrt_line_id ?>" <?
												if ($demand -> mrt_line2 == $val -> mrt_line_id)
													echo "selected";
                                                        ?>><?= $val -> value ?></option>
                                                <?
												}
                                                ?>
                                            </select>
                                            起：
                                            <select id="mrt_start2" class="full_select" style="width:100px;" name="mrt_start2">
                                                <option value="">&nbsp;&nbsp;&nbsp;&nbsp;</option>
                                                <?
                                                if($demand->mrt_line2>0){
                                                foreach($mrt[$demand->mrt_line2] as $key=>$val){
                                                ?>
                                                <option value="<?= $key ?>" <?
												if ($demand -> mrt_start2 == $key)
													echo "selected";
                                                        ?>><?= $val ?></option>
                                                <?
												}
												}
                                                ?>
                                            </select>
                                            迄：
                                            <select id="mrt_until2" class="full_select" style="width:100px;" name="mrt_until2">
                                                <option value="">&nbsp;&nbsp;&nbsp;&nbsp;</option>
                                                <?
                                                if($demand->mrt_line2>0){
                                                foreach($mrt[$demand->mrt_line2] as $key=>$val){
                                                ?>
                                                <option value="<?= $key ?>" <?
												if ($demand -> mrt_until2 == $key)
													echo "selected";
                                                        ?>><?= $val ?></option>
                                                <?
												}
												}
                                                ?>
                                            </select>
                                        </td>
                                        <th class="color2" style="background-color: honeydew;color: black;">範圍<br>
                                            <input type="button" onclick="show_area_select();" value="設定" >
                                            <input type="button" class="button" onclick="show_range_map();" value="設定" >
                                        </th>
                                        <td colspan="3">
                                            東
                                            <input type="text"  id="range_east" name="range_east" value="<?= $demand -> range_east ?>">
                                            &nbsp;&nbsp;
                                            <input type="text"  id="range_north" name="range_north" value="<?= $demand -> range_north ?>">
                                            <br>
                                            南
                                            <input type="text"  id="range_west" name="range_west" value="<?= $demand -> range_west ?>">
                                            &nbsp;&nbsp;
                                            <input type="text"  id="range_south" name="range_south" value="<?= $demand -> range_south ?>">
                                        </td>
                                    </tr>
                                    <tr>
                                        <th class="color2" style="background-color: honeydew;color: black;">公園</th>
                                        <td colspan="3">
                                            <input type="text"  id="park1" name="park1" value="<?= $demand -> park1 ?>" onclick="show_park('park1')">
                                            <input type="text"  id="park2" name="park2" value="<?= $demand -> park2 ?>" onclick="show_park('park2')">
                                        </td>
                                        <th class="color2" style="background-color: honeydew;color: black;">學校</th>
                                        <td colspan="3">
                                            <input type="text"  id="school1" name="school1" value="<?= $demand -> school1 ?>" onclick="show_school('school1')">
                                            <input type="text"  id="school2" name="school2" value="<?= $demand -> school2 ?>" onclick="show_school('school2')">
                                        </td>
                                    </tr>
                                    <tr>
                                        <th class="color2" style="background-color: honeydew;color: black;">商圈</th>
                                        <td colspan="3">
                                            <input type="text"  id="circle1" name="circle1" value="<?= $demand -> circle1 ?>" onclick="show_circle('circle1');">
                                            <input type="text"  id="circle2" name="circle2" value="<?= $demand -> circle2 ?>" onclick="show_circle('circle2');">
                                        </td>
                                        <th class="color2"  style="background-color: honeydew;color: black;">行政區</th>
                                        <td colspan="3">
                                            <input type="text"  id="administrative_area1" name="administrative_area1" value="<?= $demand -> administrative_area1 ?>" onclick="show_administrative_area('administrative_area1');">
                                            <input type="text"  id="administrative_area2" name="administrative_area2" value="<?= $demand -> administrative_area2 ?>" onclick="show_administrative_area('administrative_area2');">
                                        </td>
                                    </tr>
                                </tbody>

                        <tbody><tr>
                                <th class="color3">總預算</th>
                                <td>
                                    <input type="text" style="width:52px;" name="total_budget1" id="total_budget1" value="<?= intval($demand -> total_budget1) ?>">
                                    ~<input type="text" style="width:52px;" name="total_budget2" id="total_budget2" value="<?= intval($demand -> total_budget2) ?>"> 萬
                                </td>
                                <th class="color3">每坪預算</th>
                                <td>
                                    <input type="text" style="width:52px;" id="budget_per_ping1" name="budget_per_ping1" value="<?= intval($demand -> budget_per_ping1) ?>">~
                                    <input type="text" style="width:52px;" id="budget_per_ping2" name="budget_per_ping2" value="<?= intval($demand -> budget_per_ping2) ?>"> 萬
                                </td>
                                <td style="margin:0px;padding:0px;" colspan="4">
                                   
                                </td>
                            </tr>
                            <tr>
                                <th>屋齡</th>
                                <td>
                                    <input type="text" style="width:80px;" id="year_of_construction" name="year_of_construction" value="<?= $demand -> year_of_construction ?>">年以內
                                </td>
                                <th>物件案別</th>
                                <td colspan="5">
                                            <input type="checkbox" <?
									if (strstr($demand -> object_case_type, '1'))
										echo "checked";
                                           ?> value="1" name="object_case_type[]" class="post">中古屋

                                           <input type="checkbox" <?
										if (strstr($demand -> object_case_type, '2'))
											echo "checked";
                                           ?> value="2" name="object_case_type[]">預售

                                           <input type="checkbox" <?
										if (strstr($demand -> object_case_type, '3'))
											echo "checked";
                                           ?> value="3" name="object_case_type[]">標售
                                </td>
                            </tr>
                            
                            <tr>
                                <th style="width:75px;">落地窗座向</th>
                                <td>
                                	<input type="text" id="windows" name="windows" value="<?=$demand -> windows ?>">
                                    
                                </td>
                                <th>該戶座向</th>
                                <td>
                                	<input type="text" id="facing_the_household" name="facing_the_household" value="<?=$demand -> facing_the_household?>">
                                    
                                        
                                </td>
                                <th>大樓座向</th>
                                <td>
                                	 <input id="building_facing" name="building_facing" value="<?=$demand -> building_facing?>">
                                   
                                </td>
                                <th>指定樓層</th>
                                <td>
                                    <input type="text" style="width:34px;" id="designated_floors1" name="designated_floors1" value="<?= $demand -> designated_floors1 ?>">
                                    ~ <input type="text" style="width:34px;" id="designated_floors2" name="designated_floors2" value="<?= $demand -> designated_floors2 ?>">樓
                                    <input type="hidden" id="floors" name="floors" value="<?= $demand -> floors ?>">
                                    <input type="button" style="width:30px;" title="指定特定樓層" onclick="show_floors('floors')" value="..." class="input_background">
                                </td>
                            </tr>
                            <tr>
                                <th>物件型式</th>
                                <td>
                                		<input type="text" id="object_styles" name="object_styles" value="<?=$demand -> object_styles ?>">
                                		
                                </td>
                                <th>公共設施</th>
                                <td>
                                		<input type="text" id="public_facilities" name="public_facilities" value="<?=$demand -> public_facilities?>">
                                	
                                    
                                </td>
                                <th>附屬配備</th>
                                <td>
                                		<input type="text" id="accessories_with" name="accessories_with" value="<?=$demand -> accessories_with?>">
                                    
                                </td>
                                <th>管理</th>
                                <td>
                                		<input type="text" id="management" name="management" value="<?=$demand -> management ?>">
                                    
                                </td>
                            </tr>
                            <tr>
                                <th>房數</th>
                                <td>
                                    <input type="text" style="width:46px;" name="number_of_rooms1" id="number_of_rooms1" value="<?= $demand -> number_of_rooms1 ?>">~<input type="text" style="width:46px;" name="number_of_rooms2" id="number_of_rooms2" value="<?= $demand -> number_of_rooms2 ?>">個
                                </td>
                                <th>廳數</th>
                                <td>
                                    <input type="text" style="width:46px;" name="number_of_hall1" id="number_of_hall1" value="<?= $demand -> number_of_hall1 ?>">~<input type="text" style="width:46px;" name="number_of_hall2" id="number_of_hall2" value="<?= $demand -> number_of_hall2 ?>">個
                                </td>
                                <th>衛數</th>
                                <td>
                                    <input type="text" style="width:46px;" name="number_of_toilet1" id="number_of_toilet1" value="<?= $demand -> number_of_toilet1 ?>">~<input type="text" style="width:46px;" name="number_of_toilet2" id="number_of_toilet2" value="<?= $demand -> number_of_toilet2 ?>">個
                                </td>
                                <th>套房數</th>
                                <td>
                                    <input type="text" style="width:46px;" name="number_of_suite1" id="number_of_suite1" value="<?= $demand -> number_of_suite1 ?>">~<input type="text" style="width:46px;" name="number_of_suite2" id="number_of_suite2" value="<?= $demand -> number_of_suite2 ?>">個
                                </td>
                            </tr>
                            
                            
                            <tr>
                            	
                            		<td style="margin:0px;padding:0px;" colspan="4">
                                    <table>
                                        <tbody><tr>
                                                <td style="margin:0px;padding:0px;border:0px;">
                                                    <table style="margin:0px;padding:0px;<?
													if ($demand -> type_sell == "1")
														echo "display: table;";
													else
														echo "display:none;";
                                                           ?>" id="selected_sell">
                                                           <tbody><tr>
                                                                <th  style="width:60px;">投報率</th>
                                                                <td >
                                                                    <input type="text" style="width:56px;" name="reported_rate1" id="reported_rate1" value="<?= $demand -> reported_rate1 ?>" >
                                                                    ~ <input type="text" style="width:56px;" name="reported_rate2" id="reported_rate2" value="<?= $demand -> reported_rate2 ?>" >%
                                                                </td></tr></tbody></table>
                                                </td>
                                                <td style="margin:0px;padding:0px;border:0px;">
                                                    <table style="<?
													if ($demand -> type_rent == "1")
														echo "display: table;";
													else
														echo "display:none;";
                                                           ?>margin:0px;padding:0px;" id="selected_rent">
                                                           <tbody>
	                                                           	<tr>
	                                                                <th style="width:90px;">承租營業用途</th>
	                                                                <td><input type="text" style="width:80%;" name="leasing_business_purposes" id="leasing_business_purposes" value="<?= $demand -> leasing_business_purposes ?>"></td>
	                                                            </tr>
                                                            </tbody>
                                                   </table>
                                                </td>
                                            </tr>
                                        </tbody></table>
                                </td>
                                
                                <th>面積單位</th>
                            <td>
                                <select id="area_unit" name="area_unit" class="full_select">
                                    <?php
                                    foreach ($area_unit as $key => $val) {
                                        ?>
                                        <option value="<?= $val -> area_unit_id ?>" <?
										if ($demand -> area_unit == $val -> area_unit_id)
											echo "selected";
                                                ?>><?= $val -> value ?></option>
                                        <?
										}
                                        ?>
                                    </select>
                                </td>

                                <th>幣別</th>
                                <td>
                                    <select id="currency" name="currency" class="full_select">
                                        <?php
                                        foreach ($currency as $key => $val) {
                                            ?>
                                            <option value="<?= $val -> currency_id ?>" <?
											if ($demand -> currency == $val -> currency_id)
												echo "selected";
                                                    ?>><?= $val -> value ?></option>
                                                    <?php
													}
                                                ?>
                                    </select>
                                </td>
                            	
                            </tr>	




                    <input type="hidden" id="client_id" name="client_id" value="<?=$demand -> client_id ?>" >

                    <input type="hidden" id="client_contact_id" name="client_contact_id"  value="<?=$demand -> client_contact_id; ?>" >
                    <input type="hidden" id="ref_client_verify_code" name="ref_client_verify_code"  value="<?=$demand -> ref_client_verify_code; ?>" >
                <?php
                //echo $sshow;
                if( $sshow=="person"){
                //  if(1){
                ?>



                            <tr>
                                <th class="must_write"  style="background-color: paleturquoise;" >姓名</th>

                                <td>
                                	<?php
                                    //print_r($client_info);
                                    ?>
                                    <input type="text"  id="name" name="client[name]" value="<?= !empty($client_info) ? $client_info -> name : '' ?>" >
                                </td>
                                <th  style="background-color: paleturquoise;" >手機</th>
                                <td id="demand_t">
                                    <input type="text" style="width:130px;"  id="mobile" name="client[mobile]" value="<?= !empty($client_info) ? $client_info -> mobile : '' ?>"></td>
                                <th  style="background-color: paleturquoise;" >住家電話</th>
                                <td>
                                    <input type="text" style="width:130px;"  id="home_phone" name="client[home_phone]" value="<?=!empty($client_info) ? $client_info -> home_phone : '' ?>">
                                </td>
                                <th  style="background-color: paleturquoise;" >公司電話</th>
                                <td colspan="2">
                                    <input type="text" style="width:130px;"   id="company_phone" name="client[company_phone]" value="<?=!empty($client_info) ? $client_info -> company_phone : '' ?>">
                                </td>
                            </tr>

                            <tr>
                                <th  style="background-color: paleturquoise;" >住家地址</th>
                                <td colspan="3">
                                    <input type="text" id="home_address" name="client[home_address]" value="<?=!empty($client_info) ? $client_info -> home_address : '' ?>" style="width:90%;" onclick="show_address('home_address');">
                                </td>
                                <th   style="background-color: paleturquoise;" >大樓名稱</th>
                                <td colspan="2">
                                    <?php

									$bu_ar = array();
									foreach ($buildings as $fg => $value) {

										$bu_ar[$value -> building_name_id] = $value -> value;

									}

                                    ?>


                                    <input type="text" id="home_building_name" name="client[home_building_name]" value="<?=!empty($client_info) ? $client_info -> home_building_name : ''; ?>" style="width:130px;">
                                </td>
                            </tr>
                            <tr>
                                <th  style="background-color: paleturquoise;" >公司地址</th>
                                <td colspan="3">
                                    <input type="text" id="company_address" name="client[company_address]"  value="<?=!empty($client_info) ? $client_info -> company_address : '' ?>" style="width:90%;" onclick="show_address('company_address');">
                                </td>
                                <th  style="background-color: paleturquoise;" >公司名稱</th>
                                <td colspan="2">
                                    <input type="text" id="company_name" name="client[company_name]" value="<?=!empty($client_info) ? $client_info -> company_name : '' ?>" style="width:130px;">
                                </td>
                            </tr>
                            <tr>
                                <th  style="background-color: paleturquoise;" >Email</th>
                                <td colspan="3">
                                    <input type="text" id="email"  name="client[email]" value="<?=!empty($client_info) ? $client_info -> email : '' ?>" style="width:60%;" onblur="checkemail('email')"><input type="button" onclick="open_email('email');" value="開啟mail" class="input_background">
                                </td>
                                <th  style="background-color: paleturquoise;" >聯絡人</th>
                                <td>
                                		<input type="hidden"          name="client_contact_id" value="<?= !empty($contact_info) ? $contact_info[0] -> client_contact_id : '' ?>" >
                                    <input type="text" id="contact_name" name="contact[name]" value="<?= !empty($contact_info) ? $contact_info[0] -> name : '' ?>" style="width:130px;">
                                </td>
                                <th  style="background-color: paleturquoise;"  >聯絡人電話</th>
                                <td>
                                    <input type="text" id="contact_phone" name="contact[home_phone]" value="<?= !empty($contact_info) ? $contact_info[0] -> home_phone : '' ?>" id="contact_phone" style="width:130px;">
                                </td>
                            </tr>


                    <?php } ?>


                        <tr>
                            <th valign="middle">備註</th>
                            <td colspan="7">
                                <textarea name="remark" id="remark" style="width: 800px; height: 95px;"><?= $demand -> remark ?></textarea>
                            </td>
                        </tr>


                        <tr>
                            <th>客戶來源</th>
                            <td>
                            		<input  name="customer_source" id="customer_source" value="<?=$demand -> customer_source?>">
                                	
                            </td>
                            <th>需求等級</th>
                            <td>
                                <select name="required_level" id="required_level" class="full_select">
                                    <option value="">&nbsp;</option>
                                    <?
                                    foreach($required_level as $key=>$val){
                                    ?>
                                    <option value="<?= $val -> required_level_id ?>" <?
									if ($demand -> required_level == $val -> required_level_id)
										echo "selected";
                                            ?>><?= $val -> value ?></option>
                                    <?
									}
                                    ?>
                                </select>
                            </td>
                            <th>狀態</th>
                            <td>
                                <select name="status" id="status" class="full_select">
                                    <option value="Y" <?
									if ($demand -> status == "Y")
										echo "selected";
                                            ?>>有效</option>
                                    <option value="N" <?
									if ($demand -> status == "N")
										echo "selected";
                                            ?>>無效</option>
                                </select>
                            </td>
                            <th>無效說明</th>
                            <td>
                                <input type="text" name="invalid_description" id="invalid_description" value="<?= $demand -> invalid_description ?>">
                            </td>
                        </tr>
                        
                        
                        
                        
                        <tr>
                            <th>機密等級</th>
                            <td>
                                <select name="sercet_level" id="sercet_level"  >	
									<option value="1" <?= ($demand->sercet_level==1)?"SELECTED":"" ?> >普通</option>						
									<option value="3" <?= ($demand->sercet_level==3)?"SELECTED":"" ?> >極機密</option>
									<option value="2" <?= ($demand->sercet_level==2)?"SELECTED":"" ?> >機密</option>														
								</select>
                            </td>

                            <th>是否公開</th>
                            <td>
                                
                                <select name="is_public" id="is_public"  >														
									<option value="1" <?= ($demand->is_public==1)?"SELECTED":"" ?> >公開</option>
									<option value="2" <?= ($demand->is_public==2)?"SELECTED":"" ?> >不公開</option>							
								</select>	    		
                            </td>

                            <th>重要性</th>
                            <td>
                            	<select name="important" id="important" >
									<option value="1"   <?= ($demand->important==1)?"SELECTED":"" ?>  >普通</option>								
									<option value="3"   <?= ($demand->important==3)?"SELECTED":"" ?> >極重要</option>
									<option value="2"   <?= ($demand->important==2)?"SELECTED":"" ?> >重要</option>												
								</select>
                            </td>

                            <th style="display:none;">遮蔽欄位</th>
                            <td style="display:none;">
                               <select name="is_see" id="is_see" >														
									<option value="2" <?= ($demand->is_see==2)?"SELECTED":"" ?>>遮蔽</option>
									<option value="1" <?= ($demand->is_see==1)?"SELECTED":"" ?>>不遮蔽</option>							
								</select>
                            </td>
                        </tr>
                        
                        


                        <tr>

                            <?php
							$user_array = array();
							foreach ($users as $user) {
								$user_array[$user -> users_id] = $user -> name;
							}
                            ?>
                            <th>接待人</th>
                            <td>
                                <input type="hidden" value="<?= $demand -> front_man ?>" name="front_man" id="front_man" style="width:130px;">

                                <?php
								foreach ($user_array as $key => $value) {
									if ($key == $demand -> front_man) {
										echo $value;
									}
								}
                                ?>
                            </td>
                            <th>主管</th>
                            <td>
                                <?php
								//echo $demand->head ;
								foreach ($user_array as $key => $value) {
									if ($key == $demand -> head) {
										echo $value;
									}
								}
                                ?>
                                <input type="hidden" name="head" id="head" style="width:130px;" value="<?= $demand -> head ?>">
                            </td>
                            <th>原經紀人</th>
                            <td>
                                <input type="hidden" name="original_broker" id="original_broker" value="<?= $demand -> original_broker ?>" style="width:130px;">
                            </td>
                            <th>經紀人</th>
                            <td>
                                <?php
								foreach ($user_array as $key => $value) {
									if ($key == $demand -> broker) {
										echo $value;
									}
								}
                                ?>
                                <input type="hidden" name="broker" id="broker" value="<?=$demand -> broker ?>" >



                            </td>
                        </tr>



    <?php
        if (empty($display)) {
    ?>
                            <tr>
                                <td colspan="5"></td>
                                <td>
                                    <?php

                                        if($send_to_admin){
                                            if( $sshow=="person"){

                                    ?>
                                        <input type="button"  value="主管審核" OnClick="update_send_to_admin()" class="input_background" id="update_send_to_admin">
                                    <?php

                                            }
    									}

                                    ?>
                                </td>

                                <td class="last_save">
                                    <?php
                                    if( $sshow=="person"){
                                    ?>
                                        <input type="hidden" id="demand_id" name="demand_id" value="<?= $demand -> demand_id ?>">
                                        <input type="button"  value="存檔" class="input_background" id="demand_update">

                                    <?php } ?>
                                </td>


                                <td  class="last_save">
                                    <input type="reset" value="重置" class="input_background" style="display: none;">
                                </td>
                            </tr>
    <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>



<?php
	$this -> load -> view("showbox/address");
?>

            <div id="part_select" style="display: none;">
                <div id="part_city_div"  style="float:left;padding:10px">
                    <h3>縣市</h3>
                    <select onchange="part_city_choose();" style="width:102px;" size="30" id="part_city">
                        <option value="">請選擇</option>
                        <?
                        foreach($address_city as $key=>$val){
                        ?>
                        <option value="<?= $val -> id ?>"><?= $val -> name ?></option>
                        <?
						}
                        ?>
                    </select>
                </div>
                <div id="part_country_div"  style="float:left;padding:10px;width:102px;">
                    <h3>區域</h3>
                    <select onchange="part_country_choose();" style="width:102px;" size="30" id="part_country">
                        <option value="">請選擇</option>
                        <?
                        foreach($address_county as $key=>$val){
                        ?>
                        <option value="<?= $val -> id ?>" ><?= $val -> name ?></option>
                        <?
						}
                        ?>
                    </select>
                </div>
                <div id="part_div"  style="float:left;padding:10px;width:102px;">
                    <h3>公園</h3>
                    <select onchange="part_choose();" style="width:102px;" size="30" id="part">
                        <option value="">請選擇</option>
                    </select>
                </div>
                <div style="clear: both;"></div>
                <div id="p_div" style="padding:10px">
                    <input type="text" value="" id="part_value" >
                </div>

            </div>


            <div id="school_select" style="display: none;">
                <div id="school_city_div"  style="float:left;padding:10px">
                    <h3>縣市</h3>
                    <select onchange="school_city_choose();" style="width:102px;" size="30" id="school_city">
                        <option value="">請選擇</option>
                        <?
                        foreach($address_city as $key=>$val){
                        ?>
                        <option value="<?= $val -> id ?>"><?= $val -> name ?></option>
                        <?
						}
                        ?>
                    </select>
                </div>
                <div id="school_class_div"  style="float:left;padding:10px;width:102px;">
                    <h3>學校類別</h3>
                    <select onchange="school_class_choose();" style="width:102px;" size="30" id="school_class">
                        <option value="">請選擇</option>
                        <?
                        foreach($school_class as $key=>$val){
                        ?>
                        <option value="<?= $val -> school_class_id ?>" ><?= $val -> value ?></option>
                        <?
						}
                        ?>
                    </select>
                </div>
                <div id="school_div"  style="float:left;padding:10px;width:180px;">
                    <h3>學校</h3>
                    <select onchange="school_choose();" style="width:180px;" size="30" id="school">
                        <option value="" selected>請選擇</option>
                    </select>
                </div>
                <div style="clear: both;"></div>
                <div id="s_div" style="padding:10px">
                    <input type="text" value="" id="school_value" >
                </div>

            </div>
            <div id="emphasis_area_select" style="display: none;"  class="form_style">
                <table class="windows_choose">
                    <thead>
                        <tr>
                            <th>選擇</th>
                            <th>重點區域</th>
                            <th>說明</th>

                        </tr>
                    </thead>
                    <tbody>
                        <?
                        foreach($emphasis_area as $key=>$val){
                        ?>
                        <tr id="t_<?= $val -> emphasis_area_id ?>">
                            <td><input type="radio" value="<?= $val -> value ?>" name="emphasis_area_value" id="emphasis_area_value"></td>
                            <td><?= $val -> value ?></td>
                            <td><?= $val -> explanation ?></td>
                        </tr>
                        <?
						}
                        ?>
                    </tbody>
                </table>
            </div>
            <div id="building_name_select" style="display: none;"  class="form_style">
                <table class="windows_choose">
                    <thead>
                        <tr>
                            <th>選擇</th>
                            <th>名稱</th>
                            <th>說明</th>

                        </tr>
                    </thead>
                    <tbody>
                        <?
                        foreach($building_name as $key=>$val){
                        ?>
                        <tr id="t_<?= $val -> building_name_id ?>">
                            <td><input type="radio" value="<?= $val -> value ?>" name="building_name_value" id="building_name_value"></td>
                            <td><?= $val -> value ?></td>
                            <td><?= $val -> explanation ?></td>
                        </tr>
                        <?
						}
                        ?>
                    </tbody>
                </table>
            </div>
            <div id="object_case_name_select" style="display: none;"  class="form_style">
                <table class="windows_choose">
                    <thead>
                        <tr>
                            <th>選擇</th>
                            <th>物件編號</th>
                            <th>案名</th>

                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        foreach($object_case_name->result() as $ocn_val){
                        ?>
                        <tr id="t_<?= $key ?>">
                            <td><input type="radio" value="<?= $ocn_val -> case_name ?>" name="object_case_name_value" id="object_case_name_value"></td>
                            
                            <td><?= $ocn_val->object_no; ?></td>
                            <td><?= $ocn_val -> case_name ?></td>
                        </tr>
                        <?
						}
                        ?>
                    </tbody>
                </table>
            </div>
            <div id="circle_select" style="display: none;"  class="form_style">
                <div id="circle_city_div"  style="float:left;padding:10px">
                    <h3>縣市</h3>
                    <select onchange="circle_city_choose();" style="width:102px;" size="30" id="circle_city">
                        <option value="">請選擇</option>
                        <?
                        foreach($address_city as $key=>$val){
                        ?>
                        <option value="<?= $val -> id ?>"><?= $val -> name ?></option>
                        <?
						}
                        ?>
                    </select>
                </div>
                <div id="circle_country_div"  style="float:left;padding:10px;width:102px;">
                    <h3>區域</h3>
                    <select onchange="circle_country_choose();" style="width:102px;" size="30" id="circle_country">
                        <option value="">請選擇</option>
                        <?
                        foreach($address_county as $key=>$val){
                        ?>
                        <option value="<?= $val -> id ?>" ><?= $val -> name ?></option>
                        <?
						}
                        ?>
                    </select>
                </div>
                <div id="circle_div"  style="float:left;padding:10px;width:102px;">
                    <h3>商圈</h3>
                    <select onchange="circle_choose();" style="width:102px;" size="30" id="circle">
                        <option value="">請選擇</option>
                    </select>
                </div>
                <div style="clear: both;"></div>
                <div id="p_div" style="padding:10px">
                    <input type="text" value="" id="circle_value" style="width:300px;">
                </div>
            </div>
            <div id="floors_select" style="display: none;"  class="form_style">
                <div id="floors_div" style="padding:10px">
                    <input type="text" value="<?= $demand -> floors ?>" id="floors_value" name="floors_value" style="width:250px;">
                </div>
            </div>
            <div id="range_map_select" style="display: none;" >
                <div id="map_canvas" style="width:620px;height:600px"></div>
                <div>
                    (東北)纬度：<input type="text" id="_latitude1">经度：<input type="text" id="_longitude1"><br>
                    (西南)纬度：<input type="text" id="_latitude2">经度：<input type="text" id="_longitude2"><br>
                    <span style="color:red;">選取過程中，點擊所選區域以確定基本選區,選區大小可修改，選區可拖動(注：默認顯示台北市)</span>
                </div>
        </form>
    </div>



    <div id="administrative_area_select" style="display: none;">
            <div id="city_div"  style="float:left;padding:10px">
                <h3>縣市</h3>
                <select onchange="administrative_area_city_choose();" style="width:102px;" size="30" id="administrative_city">
                    <option value="">請選擇</option>
                    <?
                    foreach($address_city as $key=>$val){
                    ?>
                    <option value="<?= $val -> id ?>"><?= $val -> name ?></option>
                    <?
                    }
                    ?>
                </select>
            </div>
            <div id="area_div"  style="float:left;padding:10px;width:102px;">
                <h3>區域</h3>
                <select onchange="administrative_area_choose();" style="width:102px;" size="30" id="administrative_country">
                    <option value="">請選擇</option>
                </select>
            </div>
            <div style="clear: both;"></div>
            <div id="addr_div" style="padding:10px">
                <input type="text" value="" id="administrative_area" >
            </div>

        </div>
    <?= isset($footer) ? $footer : '' ?>
